<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>楼姨信息列表</title>
    <link href="../../style/css/back/style.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .userType {
            border: 2px solid #3c95c8;
            border-radius: 2px;
        }
    </style>
    <script src="../../style/js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        $(function () {
            filter();
        })

        function filter() {
            $("tr:gt(0)").remove()
            var userType = $("#userType").val()
            $.get("../../user/getUserList", {userType: userType}, function (res) {
                if (res.code === 500) {
                    alert("服务器忙,请稍后再试");
                } else if (res.code === 202) {
                    alert("登录失效,请重新登录");
                } else {
                    var str = "";
                    for (let i = 0; i < res.data.length; i++) {
                        str += "<tr align='center'>";
                        str += "<td id='numTd'>" + (i + 1) + "</td>"
                        str += "<td>" + res.data[i].account + "</td>"
                        str += "<td>" + res.data[i].nickName + "</td>"
                        var imgUrl = "http://127.0.0.1:8080/tomorrowNewsFiles/user/" + res.data[i].id +"/"+ res.data[i].newFileName
                        str += "<td><img src='" + imgUrl + "' width='30px' height='30px'></td>"
                        str += "<td>" + res.data[i].sex + "</td>"
                        str += "<td>" + res.data[i].email + "</td>"
                        str += "<td>" + (new Date(res.data[i].birthday)).toLocaleString() + "</td>"
                        str += "<td>" + res.data[i].address + "</td>"
                        str += "<td>" + (new Date(res.data[i].operateTime)).toLocaleString() + "</td>"
                        if (res.data[i].state === 0) {
                            str += "<td>正常</td>"
                        } else if (res.data[i].state === 1) {
                            str += "<td><span style='color: #139ff7'>禁言</span></td>"
                        } else {
                            str += "<td><span style='color: red'>禁用</span></td>"
                        }
                        str += "<td><a onclick='update(" + res.data[i].id + ")' href='javaScript:void(0)'>操作</a> "
                    }
                    $("#userTable").append(str);
                }
            }, "json")
        }

        function update(userId){
            location.assign("update.html?id="+userId);
        }

    </script>
</head>

<body>
<div class="rightinfo">
    <!-- 顶部按钮 -->
    <div class="tools">
        <ul class="toolbar">
            <!--增加链接-->
            用户状态<select id="userType" class="userType" onchange="filter()">
            <option value="-1">所有</option>
            <option value="0">正常</option>
            <option value="1">禁言</option>
            <option value="2">禁用</option>
        </select>

        </ul>
    </div>
    <!--数据列表 -->
    <table class="tablelist" id="userTable">
        <tr>
            <th>序号<i class="sort"><img src="../../style/img/back/px.gif"/></i></th>
            <th>账号</th>
            <th>昵称</th>
            <th>头像</th>
            <th>性别</th>
            <th>邮箱</th>
            <th>生日</th>
            <th>地址</th>
            <th>注册时间</th>
            <th>账号状态</th>
            <th>操作</th>
        </tr>
    </table>
</div>
</body>
</html>
